﻿<Window x:Class="RLProject1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:tile="clr-namespace:RLProject1"
        xmlns:clr="clr-namespace:System;assembly=System"
        xmlns:src_vm="clr-namespace:RLProject1.ViewModel"
        xmlns:src_vmh="clr-namespace:RLProject1.ViewModel.Helper"
        xmlns:src_vw="clr-namespace:RLProject1.View"
        Title="Sarsa Lambda for a grid world" Height="700" Width="800" Icon="Images\Bear_archigraphs.png">
    <!-- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation
           Abbildung aller Wpf Controls aus System.Windows.Controls
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml
           XAML Keyword aus System.Windows.Markup wie Binding, StaticRessource,...-->
    <Window.Resources>
        <!--Benutze alternativ (besser) ResourceDictionary-->
        <!-- Template zur Darstellung von GridFieldViewModel (ein einzelnes Feld)-->
        <DataTemplate DataType="{x:Type src_vm:GridFieldViewModel}">
            <!-- Stelle das mit 'GridFielView dar-->
            <src_vw:GridFieldView />
        </DataTemplate>
        <!-- Template zur Darstellung von GridViewModel (alle Felder)-->
        <DataTemplate DataType="{x:Type src_vm:GridViewModel}">
            <src_vw:GridView />
        </DataTemplate>
    </Window.Resources>
    <Window.InputBindings>
        <KeyBinding Command="{Binding DoSingleStepCommand}" Key="g" Modifiers="Ctrl"/>
        <KeyBinding Command="{Binding DoStepCommand}" Key="r" Modifiers="Ctrl"/>
        <KeyBinding Command="{Binding ToStartCommand}" Key="h" Modifiers="Ctrl"/>
        <KeyBinding Command="{Binding DoSingleStepCommand}" Key="G" Modifiers="Ctrl"/>
        <KeyBinding Command="{Binding DoStepCommand}" Key="R" Modifiers="Ctrl"/>
        <KeyBinding Command="{Binding ToStartCommand}" Key="H" Modifiers="Ctrl"/>
    </Window.InputBindings>
    <!-- Grid ist das (Default-)Layout-->
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="1*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="4*"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <!-- Properties sind als Tag-Attribute zugänglich: bspw. Menu.Height-->
        <Menu IsMainMenu="True" VerticalAlignment="Top" Grid.Row="0" Grid.ColumnSpan="2">
            <MenuItem Header="_Datei">
                <MenuItem Header="_Öffnen" IsEnabled="False" />
                <Separator />
                <!-- ClickEventHandler wird als Propertie (Click) hinzugefügt. Im CodeBehind entsteht autom. der Methodenrumpf.-->
                <MenuItem Header="S_chließen" Click="OnMenuClose">
                    <MenuItem.Icon>
                        <Image Source="/RLProject1;component/Images/X.png" Width="16" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Edit"  IsEnabled="False">
                <MenuItem Header="Cut" IsEnabled="False" />
                <MenuItem Header="Copy" IsEnabled="False" />
            </MenuItem>
            <MenuItem Header="_Ansicht" IsEnabled="False" />
            <MenuItem Header="_Hilfe">
                <MenuItem Header="_About" Click="MenuItem_About">
                    <MenuItem.Icon>
                        <Image Source="/RLProject1;component/Images/Help.png" Width="16" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
        </Menu>
        <!-- Scrollable Bereich für die Gridworld. Einbindung durch ViewModels-Property aus MainWindowViewModel, liefert GridViewModel und GridFieldViewModel;
             Darstellung durch UserControls (s.o.: Window.Ressources DataTemplate)-->
        <ScrollViewer Name="scrollViewer1" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Top" VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
            <ItemsControl ItemsSource="{Binding ViewModels}" />
        </ScrollViewer>
        <StackPanel Grid.Column="1" Grid.Row="1">
            <Grid >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1*" />
                    <ColumnDefinition Width="1*" />
                </Grid.ColumnDefinitions>
                <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center">Epsilon:</TextBlock>
                <TextBox Text="{Binding Epsilon}" Grid.Column="1" ToolTip="Explorationsrate zwischen 0.0 und 1.0"/>
                <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="1">Alpha</TextBlock>
                <TextBox Text="{Binding Alpha}" Grid.Row="1" Grid.Column="1" ToolTip="Lernrate - Gewichtung [0.0, 1.0] der neuen Erfahrung."/>
                <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="2">Gamma</TextBlock>
                <TextBox Text="{Binding Gamma}" Grid.Row="2" Grid.Column="1" ToolTip="Discount Faktor - absteigende Gewichtung [0.0, 1.0] der Rewards."/>
                <TextBlock HorizontalAlignment="Right" VerticalAlignment="Center" Grid.Row="3">Lambda</TextBlock>
                <TextBox Text="{Binding Lambda}" Grid.Row="3" Grid.Column="1" ToolTip="Trace decay factor (Spur-Zerfallfaktor in [0.0, 1.0])."/>
                <Separator Grid.Row="5" Grid.ColumnSpan="2"/>
                <StackPanel Grid.Row="6" Grid.ColumnSpan="2" Orientation="Horizontal">
                    <Button Height="30" Width="30" Command="{Binding ToStartCommand}" ToolTip="Agent wieder auf Startfeld setzen. (Strg+H)" Background="Transparent">
                        <Image Source="Images\home-small.png" />
                    </Button>
                    <Button Height="30" Width="30" Command="{Binding DoSingleStepCommand}" ToolTip="Einen Schritt ausführen. (Strg+G)" Background="Transparent">
                        <Image Source="Images\shoe.jpg" />
                    </Button>
                    <Button Height="30" Width="30" Command="{Binding DoStepCommand}" ToolTip="Bis zum Ziel laufen, max. aber 20 Schritte. (Strg+R)" Background="Transparent">
                        <Image Source="Images\icon-route.gif" Height="47" Width="30" />
                    </Button>
                </StackPanel>
                <TextBlock Grid.Row="7" Grid.ColumnSpan="2">Aktuelle Position:</TextBlock>
                <StackPanel Grid.Row="8" Grid.Column="1" Orientation="Horizontal">
                    <TextBlock Text="{Binding AgentRow}" />
                    <TextBlock Text="," />
                    <TextBlock Text="{Binding AgentCol}" />
                </StackPanel>
            </Grid>
            <TextBlock ToolTip="Verantwortlichkeitsfaktor für die aktuelle Belohnung">Eligibility:</TextBlock>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="Black" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,95 - 1,0</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="Maroon" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,85 - 0,95</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="Brown" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,65 - 0,85</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="Chocolate" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,55 - 0,65</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="Coral" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,40 - 0,55</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="DarkSalmon" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,25 - 0,40</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="LightSlateGray" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,10 - 0,52</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="LightSteelBlue" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,05 - 0,10</TextBlock>
            </StackPanel>
            <StackPanel Orientation="Horizontal">
                <Rectangle Width="12" Height="12" Fill="LightGray" Margin="5,0,0,0"/>
                <TextBlock Margin="5,0,0,0">0,0 - 0,05</TextBlock>
            </StackPanel>
        </StackPanel>
    </Grid>
    
</Window>
